/*
 * facnormal.cpp
 *
 *  Created on: Sep 15, 2012
 *      Author: heinstein & 0st3n
 */
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/contrib/contrib.hpp"
#include "facenormal.hpp"


#include <iostream>
#include <stdio.h>

using namespace cv;
using namespace std;

void facenormal ( Mat& source, Mat& dest, CascadeClassifier& leftEyeCascade, CascadeClassifier& rightEyeCascade)
{
	Mat gray;

	vector<Rect> leftEyes, rightEyes;

	cvtColor( source, gray, CV_BGR2GRAY );
	equalizeHist(gray, gray);



/*
	leftEyeCascade.detectMultiScale( gray, leftEyes,
			1.1, 2, 0
			|CV_HAAR_FIND_BIGGEST_OBJECT
			//|CV_HAAR_DO_ROUGH_SEARCH
			//|CV_HAAR_SCALE_IMAGE
			,
			Size(30, 30) );
*/
	rightEyeCascade.detectMultiScale( gray, rightEyes,
			1.1, 2, 0
			//|CV_HAAR_FIND_BIGGEST_OBJECT
			//|CV_HAAR_DO_ROUGH_SEARCH
			|CV_HAAR_SCALE_IMAGE,
			Size(50,50),
			Size(250,250)
			);


	//	for( vector<Rect>::const_iterator r = rightEyes.begin(); r != rightEyes.end(); r++)
	//{

	for( int i = 0; i < rightEyes.size(); i++ )
	{
		Point center( rightEyes[i].x + rightEyes[i].width*0.5, rightEyes[i].y + rightEyes[i].height*0.5 );
		ellipse( gray, center, Size( rightEyes[i].width*0.5, rightEyes[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );
	}
	cout << "Eye detection -- Right numbers: " << rightEyes.size() << endl;
	//	}
	cv::imshow( "DEBUG", gray );


}
